/********************************************
 * Copyright (c) 2022
 * All rights reserved.
 *
 * 文件名称：callback.c
 * 摘 要：回调函数
 *
 * 当前版本：1.0
 * 作 者：任慧
 * 完成日期：2022年7月23日
 *
 * ********************************************/

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <time.h>

#include "zlog.h"
#include "cjson_pack.h"
#include "data_sq.h"
#include "get_temp.h"
#include "get_time.h"
#include "mosquitto.h"
#include "sqlite3.h"
#include "iniparser.h"
#include "dictionary.h"

void my_connect_callback(struct mosquitto *mosq,void *obj,int rc)
{

        mqtt_t                     *mqtt_ctx = (mqtt_t *)obj;

        if (0 != rc)
        {
                zlog_error(mqtt_ctx->c,"connect failure%s",strerror(errno));
		mqtt_ctx->connect_flag = 0;
                return;
        }
	mqtt_ctx->connect_flag = 1;
	zlog_info(mqtt_ctx->c,"connect successfully!");
	return;
}

void my_disconnect_callback(struct mosquitto *mosq,void *obj,int rc)
{
        mqtt_t                     *mqtt_ctx = (mqtt_t *)obj;

	mqtt_ctx->connect_flag = 0;
	zlog_notice(mqtt_ctx->c,"get disconnect:%s",strerror(errno));
	return;
}

void my_publish_callback(struct mosquitto *mosq,void *obj,int mid)
{
        mqtt_t                     *mqtt_ctx = (mqtt_t *)obj;

	zlog_info(mqtt_ctx->c,"publish successfully!");
	return;
}

